Skip to content

Conversation

@jarhun88
Copy link
Contributor

@jarhun88 jarhun88 commented Dec 24, 2025

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.

Pull Request Template

Description

Creating a generic interface for plugging in the salesforce telemetry agent OR a custom telemetry provider.

Motivation and Context

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

How Has This Been Tested?

Related Issues

Checklist

  • I have updated the version in the package.json file by using npm run version. For example,
    use npm run version:patch for a patch version bump.
  • I have made any necessary changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have documented any breaking changes in the PR description. For example, renaming a config
    environment variable or changing its default value.

Contributor Agreement

By submitting this pull request, I confirm that:

@jarhun88 jarhun88 changed the title Telemetry @W-20481777 Setup Generic Telemetry interface Jan 13, 2026
try {
// Select provider based on configuration
switch (config.telemetry.provider) {
case 'moncloud':
Copy link
Contributor Author

@jarhun88 jarhun88 Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think having separate cases for moncloud vs custom will become even more apparent when i need to write custom metrics for the tools using telemetry.addAttributes(), as each underlying telemetry provider has different apis for doing that

/**
* Configuration for telemetry providers
*/
export interface TelemetryConfig {
Copy link
Collaborator

@anyoung-tableau anyoung-tableau Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider enforcing the requirement at the type level that providerConfig must be provided when provider === "custom" with something like:

export type TelemetryConfig = {
  enabled: boolean;
} & (
  | {
      provider: "noop" | "moncloud";
    }
  | {
      provider: "custom";
      providerConfig: Record<string, unknown>;
    }
);
Image


this.telemetry = {
enabled: telemetryEnabled === 'true',
provider: (telemetryProvider as 'noop' | 'moncloud' | 'custom') || 'noop',
Copy link
Collaborator

@anyoung-tableau anyoung-tableau Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a type guard for the telemtryProvider, similar to how this.auth is set below. Currently the runtime value could be anything.

Something like:

const telemetryProviders = ["noop", "moncloud", "custom"] as const;
type TelemetryProvider = (typeof telemetryProviders)[number];

export function isTelemetryProvider(value: unknown): value is TelemetryProvider {
    return !!(telemetryProviders.find((t) => t === value));
}

...
provider: isTelemetryProvider(telemetryProvider) ? telemetryProvider : 'noop',


case 'noop':
default:
if (config.telemetry.provider !== 'noop') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of config.telemetry.provider and the return type on this method prevent this default case from ever happening. If you remove the default case and, say, add a new provider type without adding the new case for the new provider, TypeScript will yell at you because the method could potentially now return undefined

}

// Instantiate the provider with the full config
return new ProviderClass(config);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before returning the instance, let's verify the class implements the interface. I did something similar here: https://github.com/tableau/tableau-mcp/blob/anyoung/session-store/src/server/storage/storeFactory.ts#L157

import { TelemetryAttributes, TelemetryProvider } from './types.js';

export class MonCloudTelemetryProvider implements TelemetryProvider {
private trace: any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What sets trace? And can it have a better type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants